package com.bookm.bookm.service.impl;

import cn.hutool.db.Db;
import cn.hutool.db.Entity;
import cn.hutool.db.handler.BeanListHandler;
import com.bookm.bookm.entity.Category;
import com.bookm.bookm.entity.Result;
import com.bookm.bookm.service.CategoryService;
import com.bookm.bookm.utils.ResultUtil;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class CategoryServiceImpl implements CategoryService {
    @Override
    public Result getAll() {
        List<Category> categories = null;
        try {
            // 查询所有图书分类信息并返回
            categories = Db.use().findAll(Entity.create("category"), Category.class);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return ResultUtil.success(categories);
    }
}
